<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<h:head>
	<title>Manager</title>
</h:head>
<body>
	<ui:composition template="/pages/common/commonLayout.xhtml">
		<ui:define name="content">
			<h:form>
				<p:panel header="Dane:" toggleable="true" closable="false" toggleSpeed="500" 
					closeSpeed="500" widgetVar="panel1" style="margin-bottom:20px">
						<table>
							<tr>
								<td><h:outputLabel for="firstName" value="Imie" /></td>
								<td><h:outputText id="firstName"
										value="#{managerMB.chosen.firstName}" /></td>
								<td><h:outputLabel for="lastName" value="Nazwisko:" /></td>
								<td><h:outputText id="lastName" value="#{managerMB.chosen.lastName}" /></td>
							</tr>
							<tr>
								<td><h:outputLabel for="gender" value="Plec:" /></td>
								<td><h:outputText id="gender" value="#{managerMB.chosen.gender.label}" /></td>
								<td><h:outputLabel for="spec" value="Specjalnosc:" /></td>
								<td><h:outputText id="spec" value="#{managerMB.chosen.spec.label}" /></td>
							</tr>
							<tr>
								<td><h:outputLabel for="pesel" value="Pesel:" /></td>
								<td><h:outputText id="pesel" value="#{managerMB.chosen.pesel}" /></td>
							</tr>
						</table>
					</p:panel>
					<p:panel header="Godziny pracy:" toggleable="true" closable="false" toggleSpeed="500" 
						closeSpeed="500" widgetVar="panel1" style="margin-bottom:20px">
						<c:forEach items="#{managerMB.chosen.workingDays}" var="day">
							<c:if test="#{day.working}">
								<h:outputText value="#{day.dayOfTheWeek.label} - od #{day.startHour}:00 do #{day.endHour}:00" /><br/>
							</c:if>
						</c:forEach>
					</p:panel>
					
				<p:commandButton icon="ui-icon-plus" value="Ustaw godziny pracy" action="#{managerMB.addSchedule}"/>
	  			<p:commandButton action="#{managerMB.generateSchedules}" value="Wygeneruj harmonogram" update="@all"/>
	  				
				<p:panel header="Grafiki" toggleable="true" closable="false" toggleSpeed="500" 
					closeSpeed="500" widgetVar="panel2" style="margin-bottom:20px">
					<p:dataTable var="schedule" value="#{managerMB.chosen.schedules}" paginator="true"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15" rows="10">
						<p:column headerText="Poczatek">
							<h:outputText value="#{schedule.dateStart}" >
								<f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
							</h:outputText>
						</p:column>
						<p:column headerText="Koniec">
							<h:outputText value="#{schedule.dateEnd}" >
								<f:convertDateTime pattern="dd.MM.yyyy HH:mm" />
							</h:outputText>
						</p:column>
						<p:column headerText="Akcje">
							<p:commandButton icon="ui-icon-search" action="/pages/visits/showVisits?faces-redirect=true">
								<f:setPropertyActionListener target="#{visitMB.chosenSchedule}" value="#{schedule}"/>
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</p:panel>
			</h:form>
		</ui:define>
	</ui:composition>
</body>
</html>
